//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_THREAD_INTERFACE_H
#define _UX_THREAD_INTERFACE_H

#include <Includes.h>
#include "IThreadOperation.h"

namespace Engine
{
namespace CoreSystems
{

	typedef array< IThread *, TFastCopyStrategy< IThread *>, TAllocator< IThread *> >			thread_array_t;
	typedef queue< IOperation *, TFastCopyStrategy< IOperation *>, TAllocator< IOperation *> >	operations_queue_t;


	//
	// Thread Interface
	//

	class _EXPORT_ IThread
	{
		friend class CThreadManager;
		
	protected:
		e_thread::type	_eThreadType;
		atomic_uint32	_uEmploymentRate;

	protected:
		IThread(e_thread::type eType): _eThreadType(eType), _uEmploymentRate(-1) {}
		virtual ~IThread() {}

		virtual bool _Start(e_thread_priority::type ePriority, CCore *pCore) = 0;

	public:
		virtual bool Push(IOperation *pOp, bool bHighPriority = false) = 0;
		virtual bool Pause() = 0;
		virtual bool Resume() = 0;
		virtual void Exit() = 0;
		virtual bool IsCurrent() = 0;

		void SetThreadType(e_thread::type eType)	{ _eThreadType = eType; }

		e_thread::type	GetThreadType()		const	{ return _eThreadType; }
		uint			GetEmploymentRate()	const	{ return _uEmploymentRate; }
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// _UX_THREAD_INTERFACE_H